package com.zhuoyue.system.service.impl;

import java.util.List;

import com.zhuoyue.common.annotation.DataScope;
import com.zhuoyue.common.utils.DateUtils;
import com.zhuoyue.system.domain.dto.InfraredDeviceRepDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhuoyue.system.mapper.InfraredDeviceMapper;
import com.zhuoyue.system.domain.InfraredDevice;
import com.zhuoyue.system.service.IInfraredDeviceService;

/**
 * 红外设备Service业务层处理
 *
 * @author zyzn
 * @date 2021-09-09
 */
@Service
public class InfraredDeviceServiceImpl implements IInfraredDeviceService {
    @Autowired
    private InfraredDeviceMapper infraredDeviceMapper;

    /**
     * 查询红外设备
     *
     * @param id 红外设备ID
     * @return 红外设备
     */
    @Override
    public InfraredDeviceRepDTO selectInfraredDeviceById(String id) {
        InfraredDevice infraredDevice = infraredDeviceMapper.selectInfraredDeviceById(id);
        InfraredDeviceRepDTO infraredDeviceRep = new InfraredDeviceRepDTO().doToDto(infraredDevice);
        return infraredDeviceRep;
    }

    /**
     * 查询红外设备列表
     *
     * @param infraredDevice 红外设备
     * @return 红外设备
     */
    @DataScope(deptAlias = "s_d")
    @Override
    public List<InfraredDevice> selectInfraredDeviceList(InfraredDevice infraredDevice) {
        return infraredDeviceMapper.selectInfraredDeviceList(infraredDevice);
    }

    /**
     * 新增红外设备
     *
     * @param infraredDevice 红外设备
     * @return 结果
     */
    @Override
    public int insertInfraredDevice(InfraredDevice infraredDevice) {
        infraredDevice.setCreateTime(DateUtils.getNowDate());
        return infraredDeviceMapper.insertInfraredDevice(infraredDevice);
    }

    /**
     * 修改红外设备
     *
     * @param infraredDevice 红外设备
     * @return 结果
     */
    @Override
    public int updateInfraredDevice(InfraredDevice infraredDevice) {
        return infraredDeviceMapper.updateInfraredDevice(infraredDevice);
    }

    /**
     * 批量删除红外设备
     *
     * @param ids 需要删除的红外设备ID
     * @return 结果
     */
    @Override
    public int deleteInfraredDeviceByIds(String[] ids) {
        return infraredDeviceMapper.deleteInfraredDeviceByIds(ids);
    }

    /**
     * 删除红外设备信息
     *
     * @param id 红外设备ID
     * @return 结果
     */
    @Override
    public int deleteInfraredDeviceById(String id) {
        return infraredDeviceMapper.deleteInfraredDeviceById(id);
    }
}
